<?php 
class productimage
{
        private $id;
        private $product_id;
        private $image;
        private $description;
		
        public function get_productimage($id)
        {
                $m_query = "select * from product_image where id='{$id}'";
                $m_sql = mysql_query($m_query);
                if(isset($m_sql) && mysql_num_rows($m_sql)>0)
                {
                        $m_result = mysql_fetch_assoc($m_sql);
                        $this->id = $m_result['id'];
                        $this->product_id = $m_result['product_id'];
                        $this->image = $m_result['image'];
                        $this->description = $m_result['description'];
                }
        }
		
        public function get_productimage2($product_id)
        {
                $m_query = "select * from product_image where product_id='{$product_id}'";
                $m_sql = mysql_query($m_query);
                if(isset($m_sql) && mysql_num_rows($m_sql)>0)
                {
                        $m_result = mysql_fetch_assoc($m_sql);
                        $this->id = $m_result['id'];
                        $this->product_id = $m_result['product_id'];
                        $this->image = $m_result['image'];
                        $this->description = $m_result['description'];
                }
        }
		
        public function get_id()
        {
                return $this->id;
        }
        
        public function get_product_id()
        {
                return $this->product_id;
        }
        
        public function get_image()
        {
                return $this->image;
        }
        
        public function get_description()
        {
                return $this->description;
        }

        public function set_id($id)
        {
                $this->id = $id;
        }
        
        public function set_product_id($product_id)
        {
                $this->product_id = $product_id;
        }
        
        public function set_image($image)
        {
                $this->image = $image;
        }
        
        public function set_description($description)
        {
                $this->description = $description;
        }
        
        public function create()
        {
                $m_query = "insert into product_image (product_id,image,description)
                                        values ('{$this->product_id}','{$this->image}','{$this->description}')";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
        
        public function update()
        {
                $m_query = "update product_image 
                                        set product_id='{$this->product_id}',
											image='{$this->image}',
                                            description='{$this->description}' 
                                        where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
		
        public function del()
        {
                $m_query = "delete from product_image where id={$this->id}";
                $m_sql = mysql_query($m_query);
                if($m_sql)
                        return true;
                else return false;
        }
}

?>